package com.william.jdbcplus.boot.test.dao.impl;

import com.william.jdbcplus.boot.starter.wrap.QueryLambdaBootWrap;
import com.william.jdbcplus.boot.test.dao.SysUserDepartDao;
import com.william.jdbcplus.boot.test.entity.SysUserDepart;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@AllArgsConstructor
public class SysUserDepartDaoImpl implements SysUserDepartDao {
    @Override
    public List<SysUserDepart> getUserDepartByUid(String userId) {
        //        SELECT *
        //                FROM sys_user_depart
        //        WHERE user_id = #{userId, jdbcType=VARCHAR}
        QueryLambdaBootWrap bootstrap = new QueryLambdaBootWrap();
        bootstrap
                .selectAll(SysUserDepart.class)
                .from(SysUserDepart.class)
                .eq(SysUserDepart::getUserId, userId);

        List<SysUserDepart> list = bootstrap.queryList(SysUserDepart.class);
        return list;
    }
}
